home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
610
/
bdb13
/
conv13
/
conv13.gfa
(
.txt
)
< prev
Wrap
GFA-BASIC Atari
|
1991-11-04
|
3KB
|
129 lines
'
'
' Convert Book DataBase "books.bdb" file to version 1.3
'
'
' DIM dat|(610)
dat$=SPACE$(1023)
dat_adr%=V:dat$ !|(0)
' DIM rec12|(34)
rec$=SPACE$(255)
rec_adr%=V:rec$ !rec12|(0)
title$=SPACE$(255)
titl_adr%=V:title$
com1$=SPACE$(255)
com1_adr%=V:com1$
'
CHDRIVE "E"
CHDIR "\bdbcust\conv13\"
'
OPEN "I",#1,"books.bdb"
len%=LOF(#1)
CLOSE #1
'
OPEN "R",#1,"books.bdb",12
FIELD #1,4 AS mag$,4 AS cnt$,4 AS lgn$
GET #1,1
CLOSE #1
'
mag%=CVL(mag$)
cnt%=CVL(cnt$)
lgn%=CVL(lgn$)
'
PRINT "file length: ";len%
PRINT "magick: ";HEX$(mag%,8)
PRINT "book count: ";cnt%
PRINT "string length: ";lgn%
'
mag13%=VAL("&H00077038")
mag13$=MKL$(mag13%)
'
struc_sz12%=34
struc_sz13%=34+(5*4)
'
@conv_magick("authors.bdb")
@conv_magick("series.bdb")
@conv_magick("books.bdb")
'
@conv_books
@adj_str_lgn
PRINT "new size s/b: ";(cnt%*(4*5))+(cnt%*3)+len%+512
RENAME "books.bdb" AS "books.old"
RENAME "books.new" AS "books.bdb"
'
END
> PROCEDURE conv_magick(filen$)
OPEN "R",#1,filen$,4
FIELD #1,4 AS mag$
GET #1,1
mag12$=mag$
IF CVL(mag$)=mag13%
PRINT "File: ";filen$;" --- Not correct version to change; I quit!"
CLOSE #1
END
ELSE
mag$=mag13$
PUT #1,1
CLOSE #1
PRINT "File: ";filen$;" --- Magick number has been changed."
ENDIF
RETURN
PROCEDURE conv_books
OPEN "I",#1,"books.bdb"
OPEN "O",#2,"books.new"
'
PRINT "copying info and dialog strings..."
BGET #1,dat_adr%,610 ! copy file info and dialog strings
BPUT #2,dat_adr%,610
'
resv$=STRING$(600,0)
BPUT #2,V:resv$,512
'
PRINT "converting data structure..."
FOR rec#=1 TO cnt% ! convert data structure
BGET #1,rec_adr%,34
BPUT #2,rec_adr%,34
OUT #2,0,0,0,0 ! comment2
OUT #2,1,2,3,4,5,6,7,8 ! resv 1
OUT #2,9,10,11,12,13,14,15,0
NEXT rec#
'
PRINT "converting strings..."
FOR rec#=1 TO cnt%
t1|=255
DO
INC t1|
a|=INP(#1)
POKE titl_adr%+t1|,a|
' MID$(title$,t1|,t1|)=STR$(a|)
LOOP UNTIL a|=0
'
c1|=255
DO
INC c1|
a|=INP(#1)
POKE com1_adr%+c1|,a|
' MID$(com1$,c1|,c1|)=STR$(a|)
LOOP UNTIL a|=0
'
BPUT #2,titl_adr%,t1|+1
BPUT #2,com1_adr%,c1|+1
OUT #2,0 ! comment 2
OUT #2,0 ! reserved string 1
OUT #2,0 ! reserved string 2
NEXT rec#
CLOSE #1
CLOSE #2
RETURN
> PROCEDURE adj_str_lgn
OPEN "R",#1,"BOOKS.NEW",12
FIELD #1,4 AS mag$,4 AS cnt$,4 AS lgn$
GET #1,1
lgn%=CVL(lgn$)
lgn%=lgn%+(cnt%*3) ! add three empty strings to string count
lgn$=MKL$(lgn%)
PUT #1,1
CLOSE #1
PRINT "File: ";filen$;" --- total string length has been changed."
RETURN